package com.dtw.ditouwang.ui.mine;

import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.text.Html;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.dtw.ditouwang.R;
import com.dtw.ditouwang.beans.RecordBean;

import java.util.List;

public class RecordAdapter extends RecyclerView.Adapter<RecordAdapter.Holder> {
    private List<RecordBean.DataBean> recordBeanList;

    public RecordAdapter(List<RecordBean.DataBean> recordBeanList) {
        this.recordBeanList = recordBeanList;
    }

    @NonNull
    @Override
    public Holder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
        return new Holder(LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.item_record, viewGroup, false));
    }

    @Override
    public void onBindViewHolder(@NonNull Holder holder, int i) {
        holder.timeWeather.setText(recordBeanList.get(i).getTime()+" "+recordBeanList.get(i).getRoom_type()+recordBeanList.get(i).getType()+recordBeanList.get(i).getWeather());
        holder.distance.setText(Html.fromHtml("<font><big><big><big><b><i>"+recordBeanList.get(i).getLicheng()+"</i></b></big></big></big></font>"+"&nbsp;&nbsp;公里"));
        holder.tiemSpeed.setText("时间：" + recordBeanList.get(i).getTimes_count() + "  配速：" + recordBeanList.get(i).getSpeed_distribution());
    }

    @Override
    public int getItemCount() {
        return recordBeanList.size();
    }

    class Holder extends RecyclerView.ViewHolder {
        TextView timeWeather, distance, tiemSpeed;

        public Holder(@NonNull View itemView) {
            super(itemView);
            timeWeather = itemView.findViewById(R.id.text_time_weather);
            distance = itemView.findViewById(R.id.text_distance);
            tiemSpeed = itemView.findViewById(R.id.text_time_speed);
        }
    }
}
